import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/express_company_model.dart';

ExpressCompanyModel $ExpressCompanyModelFromJson(Map<String, dynamic> json) {
  final ExpressCompanyModel expressCompanyModel = ExpressCompanyModel();
  final String? showApiResError = jsonConvert.convert<String>(json['showapi_res_error']);
  if (showApiResError != null) {
    expressCompanyModel.showApiResError = showApiResError;
  }
  final int? showApiFeeNum = jsonConvert.convert<int>(json['showapi_fee_num']);
  if (showApiFeeNum != null) {
    expressCompanyModel.showApiFeeNum = showApiFeeNum;
  }
  final int? showApiResCode = jsonConvert.convert<int>(json['showapi_res_code']);
  if (showApiResCode != null) {
    expressCompanyModel.showApiResCode = showApiResCode;
  }
  final String? showApiResId = jsonConvert.convert<String>(json['showapi_res_id']);
  if (showApiResId != null) {
    expressCompanyModel.showApiResId = showApiResId;
  }
  final ExpressBody? expressBody = jsonConvert.convert<ExpressBody>(json['showapi_res_body']);
  if (expressBody != null) {
    expressCompanyModel.expressBody = expressBody;
  }
  return expressCompanyModel;
}

Map<String, dynamic> $ExpressCompanyModelToJson(ExpressCompanyModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['showapi_res_error'] = entity.showApiResError;
  data['showapi_fee_num'] = entity.showApiFeeNum;
  data['showapi_res_code'] = entity.showApiResCode;
  data['showapi_res_id'] = entity.showApiResId;
  data['showapi_res_body'] = entity.expressBody?.toJson();
  return data;
}

extension ExpressCompanyModelExtension on ExpressCompanyModel {
  ExpressCompanyModel copyWith({
    String? showApiResError,
    int? showApiFeeNum,
    int? showApiResCode,
    String? showApiResId,
    ExpressBody? expressBody,
  }) {
    return ExpressCompanyModel()
      ..showApiResError = showApiResError ?? this.showApiResError
      ..showApiFeeNum = showApiFeeNum ?? this.showApiFeeNum
      ..showApiResCode = showApiResCode ?? this.showApiResCode
      ..showApiResId = showApiResId ?? this.showApiResId
      ..expressBody = expressBody ?? this.expressBody;
  }
}

ExpressBody $ExpressBodyFromJson(Map<String, dynamic> json) {
  final ExpressBody expressBody = ExpressBody();
  final int? allNum = jsonConvert.convert<int>(json['allNum']);
  if (allNum != null) {
    expressBody.allNum = allNum;
  }
  final int? maxSize = jsonConvert.convert<int>(json['maxSize']);
  if (maxSize != null) {
    expressBody.maxSize = maxSize;
  }
  final int? page = jsonConvert.convert<int>(json['page']);
  if (page != null) {
    expressBody.page = page;
  }
  final bool? flag = jsonConvert.convert<bool>(json['flag']);
  if (flag != null) {
    expressBody.flag = flag;
  }
  final int? retCode = jsonConvert.convert<int>(json['ret_code']);
  if (retCode != null) {
    expressBody.retCode = retCode;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    expressBody.msg = msg;
  }
  final List<Company>? expressList = (json['expressList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<Company>(e) as Company).toList();
  if (expressList != null) {
    expressBody.expressList = expressList;
  }
  return expressBody;
}

Map<String, dynamic> $ExpressBodyToJson(ExpressBody entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['allNum'] = entity.allNum;
  data['maxSize'] = entity.maxSize;
  data['page'] = entity.page;
  data['flag'] = entity.flag;
  data['ret_code'] = entity.retCode;
  data['msg'] = entity.msg;
  data['expressList'] = entity.expressList?.map((v) => v.toJson()).toList();
  return data;
}

extension ExpressBodyExtension on ExpressBody {
  ExpressBody copyWith({
    int? allNum,
    int? maxSize,
    int? page,
    bool? flag,
    int? retCode,
    String? msg,
    List<Company>? expressList,
  }) {
    return ExpressBody()
      ..allNum = allNum ?? this.allNum
      ..maxSize = maxSize ?? this.maxSize
      ..page = page ?? this.page
      ..flag = flag ?? this.flag
      ..retCode = retCode ?? this.retCode
      ..msg = msg ?? this.msg
      ..expressList = expressList ?? this.expressList;
  }
}

Company $CompanyFromJson(Map<String, dynamic> json) {
  final Company company = Company();
  final String? imgUrl = jsonConvert.convert<String>(json['imgUrl']);
  if (imgUrl != null) {
    company.imgUrl = imgUrl;
  }
  final String? simpleName = jsonConvert.convert<String>(json['simpleName']);
  if (simpleName != null) {
    company.simpleName = simpleName;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    company.phone = phone;
  }
  final String? expName = jsonConvert.convert<String>(json['expName']);
  if (expName != null) {
    company.expName = expName;
  }
  final String? url = jsonConvert.convert<String>(json['url']);
  if (url != null) {
    company.url = url;
  }
  final String? note = jsonConvert.convert<String>(json['note']);
  if (note != null) {
    company.note = note;
  }
  return company;
}

Map<String, dynamic> $CompanyToJson(Company entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['imgUrl'] = entity.imgUrl;
  data['simpleName'] = entity.simpleName;
  data['phone'] = entity.phone;
  data['expName'] = entity.expName;
  data['url'] = entity.url;
  data['note'] = entity.note;
  return data;
}

extension CompanyExtension on Company {
  Company copyWith({
    String? imgUrl,
    String? simpleName,
    String? phone,
    String? expName,
    String? url,
    String? note,
  }) {
    return Company()
      ..imgUrl = imgUrl ?? this.imgUrl
      ..simpleName = simpleName ?? this.simpleName
      ..phone = phone ?? this.phone
      ..expName = expName ?? this.expName
      ..url = url ?? this.url
      ..note = note ?? this.note;
  }
}